package com.starblink.android.common.utils

import android.util.Log
import com.starblink.android.basic.config.StorageKeys
import com.starblink.android.basic.network.base.SkGqlClient
import com.starblink.basic.storage.SkStorage
import com.starblink.rocketreserver.BuriedPointReportMutation
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 * 上报特殊点位 50003、40003、
 */
object PointReportUtils {
    fun report(jsonString: String?) {
        if (!jsonString.isNullOrEmpty()) {
            CoroutineScope(Dispatchers.IO).launch {
                val response = SkGqlClient.skMutation(
                    BuriedPointReportMutation(
                        jsonString
                    ),
                )
                if (response != null) {
                    Log.d("ProductLinkIntercept", "process:  ${response.data}")
                }
            }
        }
    }

    fun getProductLinkReportData(): String? {
        return SkStorage.getString(
            "${StorageKeys.PRODUCT_LINK_REPORT}", ""
        )
    }

    fun putProductLinkReportData(data: String) {
        SkStorage.put(
            "${StorageKeys.PRODUCT_LINK_REPORT}", data
        )
    }
}